﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Users/master.Master" AutoEventWireup="true"
    CodeBehind="SearchVideo.aspx.cs" Inherits="MediaMonitor.Users.SearchVideo" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Charting" Assembly="Telerik.Web.UI" %>
<%@ Register Src="~/Controls/AutoCompleteExtender.ascx" TagPrefix="ctrl" TagName="AutoComplete" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">

            function DateSelected(sender, eventArgs) {


                var date1 = eventArgs.get_renderDay().get_date();
                var dfi = sender.DateTimeFormatInfo;
                var formattedDate = dfi.FormatDate(date1, dfi.ShortDatePattern);

                var calE = $find("<%= calE.ClientID %>");
                var str = date1.toString();
                var ret = str.split(",");


                calE.selectDate(date1, true)
                $('#lblSelectedFromDate').text(ret[0] + '/' + ret[1] + '/' + ret[2]);
                var str2 = calE.get_selectedDates().toString();
                var ret2 = str2.split(",");

                $('#lblSelectedToDate').text(ret2[0] + '/' + ret2[1] + '/' + ret2[2]);

                //calE.get_selectedDates()
            }
            function DateSelected1(sender, eventArgs) {


                var date11 = eventArgs.get_renderDay().get_date();

                var str3 = date11.toString();
                var ret3 = str3.split(",");


                $('#lblSelectedToDate').text(ret3[0] + '/' + ret3[1] + '/' + ret3[2]);
                //calE.get_selectedDates()
            }
        </script>
    </telerik:RadCodeBlock>
    <script type="text/javascript">

        function GetDownload(id, type) {

            var iframe = document.getElementById("frmDownload");

            iframe.src = "../sitefiles/NewsAlert.aspx?id=" + id + "&type=" + type;

        }

    </script>
      <script src="../js/general.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Body" runat="server">
 <iframe id="frmDownload" width="1 " height="1" frameborder="0"></iframe>
    <div class="go-back-search">
        <a href="defaultNew.aspx?Code=Home">Go Back</a></div>
    <asp:Panel ID="pnlSearch" runat="server" CssClass="news-main">
        <table style="background-color: rgba(218, 250, 250, 0.9); border: 10px solid; width: 100%;
            padding: 20px;">
            <tr>
                <td colspan="2">
                    <h5>
                        <b>Dates</b></h5>
                    <br />
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <table>
                        <tr valign="top">
                            <td class="calender">
                                From Date
                                <asp:Label ID="lblSelectedFromDate" runat="server" ClientIDMode="Static" Text=""
                                    Font-Size="16px" ForeColor="Red"></asp:Label>
                                <br />
                                <telerik:RadCalendar AutoPostBack="false" ID="calS" runat="server" EnableMultiSelect="false"
                                    ClientEvents-OnDateSelected="DateSelected">
                                </telerik:RadCalendar>
                            </td>
                            <td>
                                <div style="width: 50px;">
                                </div>
                            </td>
                            <td class="calender">
                                To Date
                                 <asp:Label ID="lblSelectedToDate" runat="server" ClientIDMode="Static" Text="" Font-Size="16px"
                                    ForeColor="Red"></asp:Label>
                                <br />
                                <telerik:RadCalendar AutoPostBack="false" ID="calE" runat="server" EnableMultiSelect="false" ClientEvents-OnDateSelected="DateSelected1">
                                </telerik:RadCalendar>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <small><u class="ErrorText">Note:</u> only dates in blue color are valid dates having
                                    commercial's data.</small>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <br />
                    Enter the news title
                </td>
                <td>
                    <br />
                    <asp:TextBox ID="txtNewsTitle" runat="server" Width="234px"></asp:TextBox>
                </td>
            </tr>
                <tr>
                <td>
                    News Media Types
                </td>
                <td>
                    <%--<asp:DropDownList ID="lstNewsMediaType" runat="server" AutoPostBack="true"
                OnSelectedIndexChanged="lstNewsMediaType_SelectedIndexChanged">
                <asp:ListItem Text="-ALL-" Value="0"></asp:ListItem>
                <asp:ListItem Text="TV" Value="1"></asp:ListItem>
                <asp:ListItem Text="Radio" Value="3"></asp:ListItem>
                <asp:ListItem Text="Press" Value="6"></asp:ListItem>
                </asp:DropDownList>--%>
                    <table>
                        <tr>
                            <td>
                                <asp:CheckBox runat="server" ID="chkMediaAll" Text="All" Checked="true" />
                            </td>
                            <td>
                             <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                                        <asp:CheckBoxList ID="chkNewsMediaType" runat="server" AutoPostBack="true" DataValueField="MediaTypeCode"
                                            CssClass="chk" DataTextField="MediaTypeName"  OnSelectedIndexChanged="chkNewsMediaType_SelectedIndexChanged"
                                            RepeatDirection="Horizontal">
                                        </asp:CheckBoxList>
                                         </ContentTemplate>
     <Triggers>
     <asp:AsyncPostBackTrigger ControlID="chkNewsMediaType" EventName="SelectedIndexChanged" />
     </Triggers>
        </asp:UpdatePanel>
                                   
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr valign="top">
                <td>
                    Channel / Media Name
                </td>
                <td style="font-size: small;">
                  <asp:UpdatePanel ID="pnlUpdate_Media1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
                                    <ContentTemplate>
                    <asp:CheckBox ID="chkAllMedia" runat="server" Text=" Search from all Media Channels"
                        Checked="true" AutoPostBack="true" OnCheckedChanged="chkAllMedia_Changed" />
                    <asp:Panel ID="panelMediaList" class="Box" runat="server" Visible="false">
                        <asp:CheckBoxList ID="lstMedia" runat="server" DataValueField="MediaCode" DataTextField="MediaName"
                            RepeatColumns="5" RepeatDirection="Horizontal" Font-Size="8px">
                        </asp:CheckBoxList>
                    </asp:Panel>
                     </ContentTemplate>
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="chkNewsMediaType" EventName="SelectedIndexChanged" />
                                    </Triggers>
                                </asp:UpdatePanel>
                    <br />
                    <br />
                    <br />
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td colspan="3">
                    <asp:Button ID="btnSearch1" runat="server" CssClass="btn primary" Text="Search" OnClick="btnSearch_Click" />
                    
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel ID="pnlResult" runat="server" CssClass="news-main">
       <telerik:RadGrid ID="radGrid"  runat="server" CssClass="search-table" AutoGenerateColumns="false" AllowSorting="True"
            PageSize="10" AllowPaging="true" GridLines="Both" ItemStyle-Font-Size="7" EnableEmbeddedSkins="false"
            Skin="MyCustomSkin" EnableEmbeddedBaseStylesheet="False"
           MasterTableView-AllowPaging="false" PagerStyle-FirstPageText="First"
            PagerStyle-LastPageText="Last" PagerStyle-NextPageText="Next" PagerStyle-PrevPageText="Previous"
            PagerStyle-VerticalAlign="Middle">
            <MasterTableView Name="Report" ShowFooter="true" ItemStyle-BorderWidth="1" DataKeyNames="ID">
                <FooterStyle Font-Bold="true" ForeColor="AliceBlue" />
                <GroupHeaderItemStyle Font-Bold="true" Font-Size="Larger" />
                <AlternatingItemStyle Font-Size="Smaller" />
                <ItemStyle Font-Size="Smaller" />
                <Columns>
                  <telerik:GridTemplateColumn HeaderStyle-Width="30px" ItemStyle-Width="30px" HeaderText="Title" UniqueName="MediaType">
                        <ItemTemplate>
                        <b style="color: #0066FF;"><%#Eval("Title")%></b>
                          </ItemTemplate>
                    </telerik:GridTemplateColumn>
                     <telerik:GridTemplateColumn HeaderStyle-Width="30px" ItemStyle-Width="30px" HeaderText="Action" UniqueName="MediaType">
                        <ItemTemplate>
                               <p style="float: right;">
                                <a href="javascript:void(0);" onclick="PopupCenter('../sitefiles/NewsAlertvideo.aspx?SectionCode=<%#Eval("SectionCode")%>&t=f&ID=<%#Eval("ID")%>', '_blank', 350, 280); "
                                    style='display: <%#Eval("MediaTypeCode").ToString() == "1" ? "inline" : "none"  %>'>
                                    <span style='color: <%#MediaMonitor.Common.Utility.CheckVideoAvailabilityNewsAlert(Eval("ImageAudioVideoName").ToString())==true ? "green" : "red"%>;'>
                                        View </span></a>
                                <!--view for Radio-->
                                <a href="javascript:void(0);" onclick="PopupCenter('../sitefiles/NewsAlertradio.aspx?SectionCode=<%#Eval("SectionCode")%>&t=f&ID=<%#Eval("ID")%>', '_blank', 350, 280); "
                                    style='display: <%# Eval("MediaTypeCode").ToString() == "3"? "inline" : "none"  %>'>
                                    <span style='color: <%#MediaMonitor.Common.Utility.CheckRadioAvailabilityNewsAlert(Eval("ImageAudioVideoName").ToString())==true ? "green" : "red"%>;'>
                                        View </span></a>
                                <!--view for PRESS-->
                                <a href="javascript:void(0);" onclick="PopupCenterWithScroll('../sitefiles/NewsAlertpress.aspx?ID=<%#Eval("ID")%>&t=s&file=<%#Eval("ImageAudioVideoName")%>', '_blank', 750, 700); " 
                                 style='display: <%#Eval("MediaTypeCode").ToString() == "6" ? "inline" : "none"  %>'>
                                    
                                      <span style='color: <%#MediaMonitor.Common.Utility.CheckPressAvailabilityNewsAlert(Eval("ImageAudioVideoName").ToString())==true ? "green" : "red"%>;'>
                                        View
                                    </span></a>
                                    <a href="javascript:void(0);" onclick="PopupCenterWithScroll('../sitefiles/NewsAlertInternet.aspx?ID=<%#Eval("ID")%>&t=s&file=<%#Eval("ImageAudioVideoName")%>', '_blank', 750, 700); "
                                     style='display: <%#Eval("MediaTypeCode").ToString() == "9" ? "inline" : "none"  %>'>
                                       <span style='color: <%#MediaMonitor.Common.Utility.CheckInternetAvailabilityNewsAlert(Eval("ImageAudioVideoName").ToString())==true ? "green" : "red"%>;'>
                                          View
                                        </span></a>/
                                <!--download for TV-->
                                <a onclick='javascript:GetDownload("<%#Eval("ID")%>", "tv"); return false;' href="javascript:void(0);"
                                    style='display: <%#Eval("MediaTypeCode").ToString() == "1" ? "inline" : "none"  %>'>
                                    Download</a>
                                <!--download for Radio-->
                                <a onclick='javascript:GetDownload("<%#Eval("ID")%>", "radio"); return false;' href="javascript:void(0);"
                                    style='display: <%#Eval("MediaTypeCode").ToString() == "3" ? "inline" : "none"  %>'>
                                    Download</a>
                                <!--download for PRESS-->
                                <a onclick='javascript:GetDownload("<%#Eval("ID")%>", "press"); return false;' href="javascript:void(0);"
                                    style='display: <%#Eval("MediaTypeCode").ToString() == "6" ? "inline" : "none"  %>'>
                                    Download</a> <a onclick='javascript:GetDownload("<%#Eval("ID")%>", "Internet"); return false;'
                                        href="javascript:void(0);" style='display: <%#Eval("MediaTypeCode").ToString() == "9" ? "inline" : "none"  %>'>
                                        Download</a>
                            </p>
                        </ItemTemplate>
                        </telerik:GridTemplateColumn>
                </Columns>
                </MasterTableView>
                </telerik:RadGrid>
    </asp:Panel>
      <script>
          $("#ctl00_Body_chkMediaAll").click(function (eventData) {
              var checked = $(eventData.currentTarget).prop("checked");

              if (checked) {

                  $(".chk input[type=checkbox]").prop("checked", false);
              }
          });
          $(".chk input[type=checkbox]").click(function (eventData) {
              var checked = $(eventData.currentTarget).prop("checked");

              if (checked) {
                  $("#ctl00_Body_chkMediaAll").prop("checked", false);
              }
          });
          $(".chk input[type=checkbox]").live("click", function (eventData) {
              var checked = $(eventData.currentTarget).prop("checked");

              if (checked) {
                  $("#ctl00_Body_chkMediaAll").prop("checked", false);
              }
          });
       
    </script>
</asp:Content>
